package com.zhoug.zmuidemo.ui;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.RatingBar;
import android.widget.Toast;

import com.zhoug.common.utils.LogUtils;
import com.zhoug.zmui.ZMUIRatingBar;
import com.zhoug.zmuidemo.R;

public class RatingBarActivity extends AppCompatActivity {
    private static final String TAG = ">>>RatingBarActivity";
    private ZMUIRatingBar mZMUIRatingBar;
    private int progress;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rating_bar);
        findViews();
        mZMUIRatingBar.setProgress(50);
        mZMUIRatingBar.postDelayed(()->{
            mZMUIRatingBar.setProgress(75);
        },2000);
        mZMUIRatingBar.setOnProgressListener(progress -> {
            if(progress!=this.progress){
                LogUtils.d(TAG, "onCreate:"+progress);
                this.progress=progress;
                if(progress==mZMUIRatingBar.getMaxProgress()){
                    Toast.makeText(this, "(●'◡'●)", Toast.LENGTH_SHORT).show();
                }else if(progress==0){
                    Toast.makeText(this, "- _ -", Toast.LENGTH_SHORT).show();
                }
            }

        });

    }

    private void findViews() {
        mZMUIRatingBar = findViewById(R.id.zMUIRatingBar);
    }


}